<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head>
    <title></title>
  </head>
  <body>
    <h1>TreeWrapper: An easy way to add Drag and Drop support to JTrees.</h1>
    <p>
      TreeWrapper presents an easy way to add Drag and Drop support to any JTree 
      that uses a DefaultTreeModel (or derivative).
    </p>
    <p>
    For updated information on TreeWrapper visit <a target="top" href="http://www.antonioshome.net/attic/treewrapper" title="Tree Wrapper homepage">the TreeWrapper homepage</a>.
    <p>
      This is a list of features and limitations of TreeWrapper:
    </p>
    <ul>
      <li>Requires JDK5.0</li>
      <li>Any JTree with a DefaultTreeModel (or derivative) will work</li>
      <li>Gives visual feedback to the user about Drag and Drop.</li>
      <li>Minimal interference with custom CellRenderers (only borders are removed)</li>
      <li>Allows for presenting custom popup menus to the user depending on the selected node</li>
      <li>Automatic handling of copy and move operations between nodes in the same or different trees</li>
      <li>TreeTreeDnDListeners are informed about drag and drop operations between trees,
      and may cancel drag and drop operations and/or handle drag and drop operations themselves</li>
      <li>StringTreeDnDListeners are informed about drag and drop opertaionb between a String
      provider and a JTree, and again may forbid the drag and drop operation or handle the
      operation themselves.</li>
      <li>Automatic support for MutableTreeNodes (or derivatives). Does not allow drag and
      drop operations between plain TreeNodes</li>
      <li>Automatic scrolling support for large JTrees</li>
      <li>Automatically expands collapsed folders to ease the operation</li>
    </ul>
    <h1>Basic usage.</h1>
    <p>
      Using a TreeWrapper is very simple. You just need one line of code:
    </p>
    <pre>
    JTree myJTree = ...;
    // Add a wrapper around myJTree: That's all, folks!
    TreeWrapper myWrapper = new TreeWrapper( myJTree );
    </pre>
    <h1>Providing custom popup handlers</h1>
    You can provide popup menus for specific nodes by implementing the
    CustomPopupHandler interface. Then just set your custom popup handler into
    the TreeWrapper:
    <pre>
  class MyCustomPopupHandler
    implements CustomPopupHandler
  {
    public JPopupMenu getMenuAt(JTree aJTree, TreeNode aTreeNode)
    {
      private JPopupMenu myLeafPopupMenu = ...;
      private JPopupMenu myFolderPopupMenu = ...;
      if ( aTreeNode.isLeaf() )
      {
        return myLeafPopupMenu;
      }
      else
      {
        return myFolderPopupMenu;
      }
    }
  }
  ...
  
  MyCustomPopupHandler myHandler = new MyCustomPopupHandler();
  JTree myTree = ...
  // Create a wrapper for myTree
  TreeWrapper myWrapper = new TreeWrapper( myTree );
  // Set the custom popup handler into the wrapper
  myWrapper.setCustomPopupHandler( myHandler );
  
    </pre>
    <h1>Listening to tree-tree drag and drop events</h1>
    <p>
      All TreeTreeDnDListeners are informed about drag and drop operations when
      the user drags a node from a JTree into the same or another JTree (both of
      them wrapped with respective TreeWrappers, of course).
    </p>
    <p>
      By implementing a custom TreeTreeDnDListener you can control which nodes
      can be dragged into which others, and are informed when the drop operation
      finally happens.
    </p>
    <h1>Listening to String-tree drag and drop events</h1>
    <p>
      All StringTreeDnDListeners are informed about drag and drop operations between
      String sources (text fields, for instance, or even the Internet Explorer URL bar)
      into specific nodes of a JTree. These listeners indicate which nodes accept
      Strings and which nodes don't. These listeners are also informed when the
      drop operation happens, and may handle the drop operation themselves (by
      throwing a DnDVetoException or 
      just let the TreeWrapper to handle the operation itself.
    </p>
  </body>
</html>
